package bootstrap

import (
	"fmt"

	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/config"
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/template/html/v2"
)

var App *fiber.App

func SetupApp() {
	// 初始化标准 Go html 模板引擎
	engine := html.New("./views", ".html")

	App = fiber.New(fiber.Config{
		Views: engine,
	})
}

func Run() {
	// 运行服务
	err := App.Listen(":" + config.Get("app.port"))

	if err != nil {
		// 错误处理，端口被占用了或者其他错误
		fmt.Println(err.Error())
	}
}
